<?php

class Jd_user_total_model extends MY_Model {


    public function __construct()
    {
        $this->modelename='Jd_user_total_model';
        $this->tablename='user_total';
        parent::__construct();
    }


    /**
     *
     * 更新用户统计数据信息
     * @param $array
     * @return type
     */
    public  function  updata_user_total($sql,$user_id){
        $sql2="select 1 from jd_user_total where user_id=$user_id";
        $r= $this->GetBySql($sql2,0);
        if(empty($r)){
           $this->add($this->tablename,array('user_id'=>$user_id));
        }
        return  $this->db->query($sql);
    }



     public function getonebyuserid($userid, $select = '*')
     {
         $table=$this->tablename;
         return $result = $this->db->select($select)->from($table)->where("user_id=".$userid)->get()->result_array();
     }


}
